
function setSecondsf(val){
	if(val==0){
	      Ti_companyInfo.getNameEmail(function(ret){
	      	document.getElementById("sort2").innerHTML=ret;
	       });	
	
	}else if(val==1){
	     Ti_personalInfo.getNameEmail(function(ret){
	      	document.getElementById("sort2").innerHTML=ret;
	       });
	}
}
function getemail(val){
    var tag = false;
    if(document.getElementById("email").value=="" ||document.getElementById("email").value ==null){
         document.getElementById("email").value = trim(val);
    }  
    var arr = (document.getElementById("email").value).split("|"); 
    for(var i = 0; i != arr.length; i++){
          if(val ==arr[i]) tag = true;
    }
    if(tag!=true)
    document.getElementById("email").value =  document.getElementById("email").value + "|"+trim(val);
}

function trim(str){
    return str.replace(/(^\s*)|(\s*$)/g,"");
  }



function submitForm() {

		
	if(trim(document.getElementById("title").value)=="")
	{
	  alert("邮件标题不能为空！");
	  return false;
	}
	
	if(trim(document.getElementById("email").value)=="")
	{
	  alert("邮件地址不能为空！");
	  return false;
	}	
	
	 var str=CKEDITOR.instances.content.getData();
		str=str.replace("<p>","");
		str=str.replace("</p>","");
		str=trim(str);
		if(str==""){
			alert("邮件内容不能为空！");
			CKEDITOR.instances.content.focus();
				return false;
			}
	
	
	if(trim(document.getElementById("pre_date").value)=="")
	{
	  alert("预约时间不能为空!");
	  return false;
	}	
	if(!checkEmails()) return false;
	//return false;
	document.addForm.submit();
}
function checkEmails(){
    var ss = document.getElementById("email").value;
	   var arr = ss.split("|");
	   //alert(arr.length);
	   for(var i =0; i < arr.length; i++){
	         if(arr[i].isEmail()) {
			      //  alert("---"+arr[i]+"---这是一个正确的Email");
					//return true;
			 }else{
			        alert("这不是一个正确的Email!");
			        return false;
			 }
	   }
	   return true;
}
String.prototype.isEmail = function()
{    
     var re = /^[0-9a-zA-Z]+([\.\-\_][0-9a-zA-Z]+)*@[0-9a-zA-Z]+([\.\-][0-9a-zA-Z]+)*.[a-zA-Z]+$/;
	 return re.test(this);
}